#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/11/27 08:54|08:54
# @Author  : yangdingyi
# @File    : 反转字符串中的单词 III
# @Software: PyCharm


class Solution:
    def reverseWords(self, s: str) -> str:
        ss = s.strip(' ').split(' ')
        arr = []
        for si in ss:
            # arr_si = si.split('')
            # 需要使用list构造函数，split不能分割成单个字符
            arr_si = list(si)
            arr_si.reverse()
            arr.append(''.join(arr_si))
        return ' '.join(arr)


solve = Solution()

s = "Let's take LeetCode contest"
print(s)
print(solve.reverseWords(s))

